
function plugin (Vue) {
  if (plugin.installed) {
    return
  }

  !Vue.prototype.$auth && Object.defineProperties(Vue.prototype, {
    $auth: {
      get () {
        const _this = this
        return (action) => {
          if (process.env.VUE_APP_PERMISSION) {
            return true
          }
          const userInfo = _this.$store.getters.userInfo
          const actionPerms = userInfo.actionPerms
          return actionPerms.includes(action)
        }
      }
    }
  })
}

export default plugin
